﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseData.Exts;
using BaseData.Models;
using BaseLib.Helper;
namespace WebUI.UserControls.Share
{
    public partial class Navigate : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            /// using (var ctx = new ContextExt())
            /// {
            ///     var result = (from q in ctx.Web_Base_News_Node
            ///                   where q.ParentId.Value == 0 && q.FlagStatus == 1 && q.flagMenu == 1
            ///                   orderby q.SortId descending select q).ToList();
            ///     if (!result.Any()) result.Add(new Web_Base_News_Node { ParentId = 0, Title = "无记录", Folder = "javascript: void(0);", });
            ///     this.RepeaterX.DataSource = result;
            ///     this.RepeaterX.DataBind();
            ///     this.RepeaterA.DataSource = result;
            ///     this.RepeaterA.DataBind();
            /// }
        }
        protected void RepeaterX_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            /// using (var ctx = new ContextExt())
            /// {
            ///     //判断里层repeater处于外层repeater的哪个位置（ AlternatingItemTemplate，FooterTemplate，HeaderTemplate，，ItemTemplate，SeparatorTemplate）
            ///     if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) return;
            ///     var rep = e.Item.FindControl("RepeaterY") as Repeater;          //找到里层的repeater对象
            ///     if (rep == null) return;
            ///     var row = (Web_Base_News_Node)e.Item.DataItem;              //找到节点Repeater关联的数据项 
            ///     var result = (from q in ctx.Web_Base_News_Node
            ///                   where q.ParentId == row.PkId && q.FlagStatus == 1 && q.flagMenu == 1
            ///                   orderby q.SortId descending select q).ToList();
            ///     if (!result.Any()) return;
            ///     result.ForEach(f =>
            ///     {
            ///         f.Folder = row.Folder;
            ///         f.Url = f.Url.IsNotNullOrWhiteSpace()
            ///             ? f.Url
            ///             : "?nodeid=" + f.PkId;
            ///         //: ((from q in ctx.Web_Base_News_Info where q.NodeId == f.PkId select q).Count() > 1 ? "?nodeid=" : "?id=") + f.PkId;
            ///         ;
            ///     });
            ///     rep.DataSource = result;
            ///     rep.DataBind();
            /// }
        }
    }
}